package com.aaa.config;

import com.aaa.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

//继承WebMvcConfigurer接口用于自定义配置拦截器，静态资源访问，跨域请求，简单的页面映射，视图解析器，自定义方法参数解析器添加自定义返回值处理器，自定义 HTTP 消息转换器（如 JSON、XML）
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource
    LoginInterceptor loginInterceptor=new LoginInterceptor();
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
      registry.addInterceptor(loginInterceptor).
              addPathPatterns("/**").
              excludePathPatterns("/login");
    }
}
